#pragma once
//
//  memory_pool.hpp
//  JanMalloc
//
//  Created by janhit on 2022/4/16.
//

#ifndef memory_pool_hpp
#define memory_pool_hpp

#include <thread>
#include <map>
#include <atomic>
#include "../Concurrency/SpinLock.hpp"
#include "TypesDef.hpp"

#include <functional>
#include <mutex>


namespace MMFAlloc{

class ThreadAllocator;

class MemoryPool
{
    
private:
    
    std::atomic<bool> mIsExit;
    MMF::SpinLock mLock;
    std::map<std::thread::id, ThreadAllocator*> mThdAllocator;
    std::thread* mCleaner;
    
public:
    
    MemoryPool();
    ~MemoryPool();
    
    void* Alloc(u32 size);
    void Free(void* addr);
};

}

#endif /* memory_pool_hpp */
